﻿namespace codeGenerator.model
{
    public class ColumnMeta
    {
        public string TableName { get; set; }
        public string ColumnName { get; set; }
        public string ColumnType { get; set; }
        public string ColumnDesc { get; set; }

        public ColumnMeta()
        {
        }

        public ColumnMeta(string tableName, string columnName, string columnType, string columnDesc)
        {
            this.TableName = tableName;
            this.ColumnName = columnName;
            this.ColumnType = columnType;
            this.ColumnDesc = columnDesc;
        }

        /**
         * 获取大驼峰,get,set方法使用  
         * sNo -> sNo
         * userName -> UserName
         */
        public string GetUpperCamelCase()
        {
            if (ColumnName.Length > 1)
            {
                // userName -> UserName
                if ((ColumnName[0] >= 'a' && ColumnName[0] <= 'z') && (ColumnName[1] >= 'a' && ColumnName[1] <= 'z'))
                {
                    string substring = ColumnName.Substring(0, 1).ToUpper() + ColumnName.Substring(1);
                    return substring;
                }
            }
            
            // 单字符成员变量
            if (ColumnName.Length == 1)
            {
                return ColumnName.ToUpper();
            }


            return ColumnName;
        }
    }
}